package com.irs.irsforum.entity;

import java.io.Serializable;

import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author yihuili
 * @since 2020-02-12
 */
@Data
@TableName("forum_message")
public class Message extends Model<Message> {

    private static final long serialVersionUID = 1L;

	@TableId(value="id", type= IdType.AUTO)
	private Long id;
    /**
     * 消息发出者
     */
	private Long sender;
	private String senderNickName;
    /**
     * 消息接收者
     */
	private Long recipient;
	private String recipientNickName;
	@TableField("post_id")
	private Long postId;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer isExist;
	@TableField("creationTime")
	private Timestamp creationTime;
	private Integer isRead;
	private String title;

    @JsonInclude(JsonInclude.Include.NON_NULL)
	private List<Long> recommendStudentList;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	public Timestamp getCreationTime() {
		return creationTime;
	}

	public Message(Long sender, Long postId) {
		this.sender = sender;
		this.postId = postId;
	}

	public Message() {
	}

	@Override
	protected Serializable pkVal() {
		return this.id;
	}

	@Override
	public String toString() {
		return "Message{" +
				"id=" + id +
				", sender=" + sender +
				", senderNickName='" + senderNickName + '\'' +
				", recipient=" + recipient +
				", recipientNickName='" + recipientNickName + '\'' +
				", postId=" + postId +
				", isExist=" + isExist +
				", creationTime=" + creationTime +
				", isRead=" + isRead +
				", title='" + title + '\'' +
				", recommendStudentList=" + recommendStudentList +
				'}';
	}
}
